home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d7 / jmd4tlx.arc / JMODEM.DOC < prev    next >
Text File  |  1989-03-30  |  36KB  |  1,009 lines

  1.  
  2.                                   J M O D E M
  3.                               File Transfer System
  4.                                  Compliments of
  5.                                Richard B. Johnson
  6.                                 PROGRAM EXCHANGE
  7.                                  (303) 440-0786
  8.                                 January 10, 1989
  9.  
  10.           General:
  11.           First Let me get this over with.
  12.           MS-DOS is a registered trademark of Microsoft Corporation
  13.           IBM, IBM-PC, IBM-XT, AT, are registered trademarks of
  14.           International Business Machines, Inc. WILDCAT! is a trade-
  15.           mark of Mustang Software. XMODEM is a public-domain file-
  16.           transfer protocol developed by Ward Christensen.
  17.  
  18.           JMODEM is released into the public domain. As with most
  19.           public-domain protocols, you are advised that there is no
  20.           implied warranty of any kind. The source-code is provided so
  21.           that you may determine for yourself if this program may
  22.           serve a useful purpose. It is written in Microsoft MASM
  23.           Assembly-language using good standards of engineering
  24.           practice. It does not use any strange or "undocumented"
  25.           functions of the MS-DOS operating system.
  26.  
  27.                 PLEASE UPLOAD THIS FILE (The ARC file) to as many
  28.                 BBS systems as you can so that it gets installed
  29.                 all around the country.
  30.  
  31.           Introduction:
  32.           JMODEM is a new file-transfer protocol developed to be used
  33.           as an "external protocol" on BBS systems and personal com-
  34.           puters using the IBM-PC/AT/XT structure and the MS-DOS oper-
  35.           ating system.
  36.  
  37.           This file-transfer system features:
  38.  
  39.                 o       16-bit CRC for verification
  40.                 o       File size is exactly maintained
  41.                 o       Data compression.
  42.                 o       Rapid host/remote synchronization.
  43.                 o       Variable-length transmission blocks which,
  44.                         if there are few errors, increase to 8192
  45.                         data-bytes in length.
  46.                 o       Flow control (automatic)
  47.                 o       Hangup protection
  48.                 o       Aborted files are saved
  49.                 o       Files being overwritten are renamed to
  50.                         ".OLD", rather than deleted.
  51.                 o       COM1 - COM4 support.
  52.                 o       Interrupt on received characters allows data
  53.                         to be received while the previous block is
  54.                         being written to disk. This provides almost
  55.                         continuous data transmission without long
  56.                         waits between blocks.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                                      - 1 -
  63.           
  64.                                                JMODEM Protocol  Page 2
  65.  
  66.  
  67.           JMODEM is not for everyone! It does not have any pretty
  68.           screens to dazzle the user. It is designed to maximize the
  69.           amount of data that can be transferred in a given time (and
  70.           reduce telephone cost). It does this by sending very long
  71.           blocks of data and encoding (compressing) the data wherever
  72.           possible. Since long blocks of data are subject to many
  73.           transmission errors, a 16 bit CRC is used to determine the
  74.           data integrity. As many as ten retries are made if the data
  75.           is not correctly received. If you have a noisy telephone
  76.           circuit, you will find that JMODEM will abort more often
  77.           than the XMODEM protocol which sends very short blocks. A
  78.           future version that will be downward-compatible with the
  79.           existing version is being developed that will do "heroic"
  80.           retries and will even go down to a 16-byte block-lengths if
  81.           that's what is necessary to get the data transferred.
  82.  
  83.           Once synchronization between the remote computer and the
  84.           host are established, JMODEM paints a status block on the
  85.           screen that shows how the file transfer is going. The status
  86.           screen shows the block being transmitted (or the last re-
  87.           ceived), the length of the block, and the total bytes having
  88.           been transmitted (or received). A special synchronization
  89.           routine is used so that the first block is not thrown away
  90.           as happens so often in XMODEM type routines. During the
  91.           synchronization routine, where the host is waiting for the
  92.           user to enter the proper file parameters (a 30 second wait).
  93.           You can abort immediately by sending a control X (^X). After
  94.           actual file transfer begins, ie. when you see the status
  95.           window on the screen, no input from the keyboard is pos-
  96.           sible. You send a control BREAK to abort the transmission
  97.           (or ^C). In this case, the program will abort after the
  98.           block being sent/received is complete. This could take 15 or
  99.           more seconds with long blocks so be patient.
  100.  
  101.           In the event that carrier is lost (the user disconnected),
  102.           the file-transfer program will also abort. This, too, could
  103.           take as long as 15 seconds. JMODEM has logic to determine if
  104.           the modem carrier was present when it started. This will
  105.           allow you to transfer files between computers with a wire
  106.           without having to tie the RLSD lead high.
  107.  
  108.           How it works:
  109.           The block size starts out at 512 bytes (or the actual bytes
  110.           in the file -- whichever is less). To this is added a 6-byte
  111.           overhead. If the block transfer occurred without any re-
  112.           tries, the block length is increased by 512 bytes to 1024
  113.           bytes. As long as the transmission was successful without
  114.           incurring any re-tries, the block-length increases to a max-
  115.           imum of 8192 bytes. There is still the same 6-byte overhead
  116.           so the maximum block length will actually be 8198 bytes. Any
  117.           time there are retries, the block length (on the next new
  118.           string) is decreased by 512 bytes. The string-length is
  119.           never reduced to less than 512 bytes due to errors. When the
  120.  
  121.  
  122.  
  123.  
  124.  
  125.                                      - 2 -
  126.           
  127.                                                JMODEM Protocol  Page 3
  128.  
  129.           last bytes are read from the file, the block length may be
  130.           as little as 7 bytes (one data byte, plus the 6 byte over-
  131.           head). The file size as received will be exactly the file
  132.           size as transmitted. XMODEM will "round-up" the file size to
  133.           the next higher block. This means that MS-DOS's COMP (com-
  134.           pare) will always fail when you attempt to check files that
  135.           have been sent by XMODEM and many other protocols.
  136.  
  137.           When the file is read, an attempt is made to compress the
  138.           data using the well-known RLL process where multiple bytes
  139.           are compressed into a 4-byte statement.
  140.  
  141.           For instance a string that looks like this (hex):
  142.                 A0 A0 A0 A0 A0 A0 A0 A0 A0 A0 A0 A0 A0 A0 A0 A0
  143.           Gets compressed into this:
  144.                 BB 0F 00 A0
  145.                  |  |  |  |__________ Byte to repeat
  146.                  |  |  |_____________ High byte of repeat length
  147.                  |  |________________ Low byte of repeat length
  148.                  |___________________ Sentinel Byte
  149.  
  150.           The sentinel-byte (BBH), when encountered in a data stream
  151.           will get expanded to four bytes. Therefore, it is possible
  152.           for the "compressed" data string to actually be longer than
  153.           the original. If this occurs, the original string is sent
  154.           rather than the longer encoded one. Since the kind of data
  155.           sent can be different from block-to-block, it is necessary
  156.           to send a control-byte along with the data so the receiver
  157.           had determine how to operate on the data.
  158.  
  159.           This is the control structure:
  160.  
  161.           00 02 00 0B 01 02 03 04 05 06 07 08 09 0A .... 0A EA
  162.            |  |  |  |  |                                 |  |_ CRC
  163.            |  |  |  |  |                                 |____ CRC
  164.            |  |  |  |  |______________________________________ data
  165.            |  |  |  |_________________________________________ rec.
  166.            |  |  |____________________________________________ control
  167.            |  |_______________________________________________ length
  168.            |__________________________________________________ Length
  169.  
  170.           Two bytes are used for the string length and two bytes are
  171.           used for the CRC. As is standard in memory, the high-byte
  172.           looks "to people using DEBUG" swapped with the low byte. The
  173.           data is transmitted exactly as the memory image.
  174.  
  175.           The length (a word) begins the string so the receiver may
  176.           know exactly how may bytes to receive.
  177.  
  178.           The control byte is bit-mapped to 8 possibilities. The ones
  179.           most important are:
  180.  
  181.                         NORMAL DATA
  182.                         COMPRESSED DATA
  183.  
  184.  
  185.  
  186.  
  187.  
  188.                                      - 3 -
  189.           
  190.                                                JMODEM Protocol  Page 4
  191.  
  192.                         END OF FILE
  193.                         ABORT
  194.  
  195.           This is now the receiver "knows" what to do with the data.
  196.  
  197.           The CRC is generated using this polynomial:
  198.  
  199.           X =  X + X^(2(n-mod 7)).......  Where n = t(n-1)
  200.                                          And t = string length
  201.  
  202.           It has the advantage of simplicity in assembly-language
  203.           programming and will detect errors with a probability of
  204.           about  one undetected error in 2^132 (which is a very large
  205.           number). It does not correct errors so its not important to
  206.           use some "standard" function to generate the CRC.
  207.  
  208.           Support for COM3 and COM4 have been added on revision level
  209.           V1.05 . Note that the standards for port locations are de-
  210.           facto standards only and may not be the ports actually used
  211.           in your computer. Please modify the communications port
  212.           structures at the beginning of the assembly-language program
  213.           to match your system parameters if they are different. The
  214.           modifications should be done to the STRUCTURES, not to the
  215.           EQUATES!
  216.  
  217.           Revision level V1.09 brings musical exit status. If the file
  218.           transfer was successful, the computer plays "victory". If
  219.           the file transfer was aborted, the computer plays "retreat".
  220.           Since the BBS SysOp is unlikely to want his computer to play
  221.           bugle-calls well into the evening, the user has the option
  222.           of turning the music off. This is done by setting an en-
  223.           vironment variable string:
  224.  
  225.           SET JMODEM=SHUTUP
  226.  
  227.                 ... Will accomplish the desired result.
  228.           Usage:
  229.           This program uses parameters on the command line.
  230.  
  231.           JMODEM S <filename.typ>       ( Sends a file to COM1:)
  232.           JMODEM R <filename.typ>       ( Receives a file from COM1:)
  233.           JMODEM S1 <filename.typ>      ( Sends a file to COM1:)
  234.           JMODEM R1 <filename.typ>      ( Receives a file from COM1:)
  235.           JMODEM S2 <filename.typ>      ( Sends a file to COM2:)
  236.           JMODEM R2 <filename.typ>      ( Receives a file from COM2:)
  237.  
  238.           After version 1.05, JMODEM supported communications adapter
  239.           ports 1 through 4.
  240.  
  241.           In a batch file, <filename.typ> may be a substitution
  242.           character.
  243.           JMODEM S2 %1                  ( Sends a file to COM2:)
  244.           JMODEM R2 %1                  ( Receives a file from COM2:)
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.                                      - 4 -
  252.           
  253.                                                JMODEM Protocol  Page 5
  254.  
  255.                       Setting up a Communications Program
  256.                         External File-Transfer Protocol.
  257.  
  258.           On my system, TELIX resides in the C:\TELIX directory. A
  259.           copy of JMODEM.COM is also in that directory. TELIX passes
  260.           the filename as the %3 parameter. Therefore the contents of
  261.           JUP.BAT is:
  262.  
  263.                         C:\TELIX\JMODEM S1 %3
  264.  
  265.           The contents of JDOWN.BAT are:
  266.  
  267.                         C:\TELIX\JMODEM R1 %3
  268.  
  269.           If I wished to receive in the "batch" mode, I could make a
  270.           file like this. Notice that some communications programs do
  271.           not allow multiple file names. Note that the comments "!"
  272.           are NOT ALLOWED in a DOS batch file.
  273.  
  274.                         :DO_LOOP                   ! Return here
  275.                         IF "%3" == "" GOTO DONE    ! More parameters?
  276.                         C:\TELIX\JMODEM R1 %3      ! Execute JMODEM
  277.                         IF ERRORLEVEL 1 GOTO DONE  ! Abort on error
  278.                         SHIFT                      ! %4 becomes %3
  279.                         GOTO DO_LOOP               ! Continue
  280.                         :DONE                      ! Exit batch file
  281.  
  282.           If you do not know what "%" parameters are used to pass the
  283.           file name, all you have to do is make a "dummy" batch file
  284.           that contains the following:
  285.  
  286.                         @ECHO OFF
  287.                         ECHO %1
  288.                         ECHO %2
  289.                         ECHO %3
  290.                         ECHO %4
  291.                         ECHO %5
  292.                         PAUSE
  293.  
  294.           When this is executed, you will see something like this:
  295.  
  296.                 1200
  297.                 1
  298.                 FILENAME.TYP
  299.                 ECHO is off
  300.                 ECHO is off
  301.                 Strike a key when ready . . .
  302.  
  303.           The first line contains "1200" which is the baud rate. This
  304.           means that the %1 parameter contains the baud rate.
  305.  
  306.           The second line contains "1" which is the communications
  307.           adapter port being used. This means that the port is being
  308.           passed as the %2 parameter.
  309.  
  310.  
  311.  
  312.  
  313.  
  314.                                      - 5 -
  315.           
  316.                                                JMODEM Protocol  Page 6
  317.  
  318.  
  319.           The third line contains "FILENAME.TYP" which is the file
  320.           name. This means that the file name is being passed as the
  321.           %3 parameter.
  322.  
  323.           The fourth and fifth lines contain nothing to echo so DOS
  324.           replies the current state of the echo function which is
  325.           "off".
  326.  
  327.           PCPLUS handles the file name passing a little bit different.
  328.           If I execute the same "dummy" batch file from the PCPLUS
  329.           directory, the response is:
  330.  
  331.                 FILENAME.TYP
  332.                 ECHO is off
  333.                 ECHO is off
  334.                 ECHO is off
  335.                 ECHO is off
  336.                 Strike a key when ready . . .
  337.  
  338.           This shows us that PCPLUS passes the file name as the first
  339.           parameter and there are no other parameters. However, If I
  340.           put more parameters on the command line within PCPLUS, they
  341.           will get sent to the batch file. The response is:
  342.  
  343.                 FILENAME.001
  344.                 FILENAME.002
  345.                 FILENAME.003
  346.                 FILENAME.
  347.                 ECHO is off
  348.                 Strike a key when ready . . .
  349.  
  350.           Therefore PCPLUS allows up to four file names to be passed
  351.           providing there's room on the command line.
  352.  
  353.           Notice that these two communications programs check the
  354.           default directory for the external protocol batch file
  355.           FIRST! Therefore you must make certain that there are no
  356.           other similarly-named batch files in the current directory
  357.           or within the current path. Failure to do so will cause the
  358.           improper execution of the wrong batch file. Lets say that
  359.           the path was "C:\DOS;C:\TOOLS;C:\PCPLUS;C:\TELIX;C:\QMODEM".
  360.           If you named all your JMODEM external protocol batch files
  361.           with the same name, and you were attempting to use an ex-
  362.           ternal file transfer protocol from QMODEM, the batch file
  363.           designed to operate with PCPLUS would be the first one
  364.           "found" and executed since the search-path will search the
  365.           \PCPLUS directory before the \QMODEM directory. You prevent
  366.           the execution of the incorrect batch file by calling them
  367.           slightly different names.
  368.  
  369.           When setting up external protocols, remember to configure
  370.           the communications program so that it prompts you for the
  371.           file names. Unlike some protocols, JMODEM does not transfer
  372.  
  373.  
  374.  
  375.  
  376.  
  377.                                      - 6 -
  378.           
  379.                                                JMODEM Protocol  Page 7
  380.  
  381.           the file name. You can use any file name that you wish. You
  382.           must pass the file name to JMODEM since it must know the
  383.           name of the file being transmitted or received. There are no
  384.           defaults.
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.                                      - 7 -
  441.           
  442.                                                JMODEM Protocol  Page 8
  443.  
  444.                             Setting up a BBS System
  445.                         External File-Transfer Protocol.
  446.  
  447.  
  448.           If you are running a WILDCAT! bulletin board, the external
  449.           protocol files can be set up like this:
  450.  
  451.                         (JUP.BAT)
  452.                         CD D:\WILDCAT\PROTOCOL
  453.                         IF EXIST TRANSFER.BAD DEL TRANSFER.BAD
  454.                         JMODEM R1 %3
  455.                         IF ERRORLEVEL 1 GOTO END
  456.                         COPY %3 %4
  457.                         :END
  458.                         DEL %3
  459.  
  460.                         (JDOWN.BAT)
  461.                         CD D:\WILDCAT\PROTOCOL
  462.                         IF EXIST TRANSFER.BAD DEL TRANSFER.BAD
  463.                         JMODEM S1 %3
  464.                         IF ERRORLEVEL 1 GOTO BAD
  465.                         GOTO END
  466.                         :BAD
  467.                         COPY ALL.OK TRANSFER.BAD
  468.                         :END
  469.  
  470.           There are many variations available. Since WILDCAT! supports
  471.           batch-mode downloading, you could set up the batch file like
  472.           this:
  473.  
  474.                         (JDOWN.BAT)
  475.                         CD D:\WILDCAT\PROTOCOL
  476.                         IF EXIST TRANSFER.BAD DEL TRANSFER.BAD
  477.                         :DO_LOOP
  478.                         IF "%3" == "" GOTO END
  479.                         JMODEM S1 %3
  480.                         IF ERRORLEVEL 1 GOTO BAD
  481.                         SHIFT
  482.                         GOTO DO_LOOP
  483.                         :BAD
  484.                         COPY ALL.OK TRANSFER.BAD
  485.                         :END
  486.  
  487.           WILDCAT! checks the \PROTOCOL directory to see if the file
  488.           TRANSFER.BAD has been created. If it exists, it announces
  489.           that the file transfer has failed. It also announces "Error
  490.           with external protocol .. ". It does this when, in fact,
  491.           WILDCAT!  has made an error itself. In many cases WILDCAT!
  492.           will "find" the file TRANSFER.BAD when it DOES NOT EXIST! In
  493.           spite of this bug, WILDCAT! is one of the most reliable BBS
  494.           systems supporting external protocols.
  495.  
  496.           When setting up batch files remember that there is also a
  497.           bug in all DOS versions. The "IF ERRORLEVEL " statement does
  498.  
  499.  
  500.  
  501.  
  502.  
  503.                                      - 8 -
  504.           
  505.                                                JMODEM Protocol  Page 9
  506.  
  507.           NOT test the actual value of ERRORLEVEL! Instead it checks
  508.           to see if the returned value is EQUAL or GREATER than the
  509.           tested value. If you were to put the statement:
  510.  
  511.                         IF ERRORLEVEL 0 GOTO GOOD
  512.  
  513.           .... in a batch file, the execution would ALWAYS branch to
  514.           label "GOOD" regardless of the actual ERRORLEVEL returned!
  515.           More about bugs when we get to the "BAD BBS" section towards
  516.           the end.
  517.  
  518.           JMODEM does not require any information about handshaking.
  519.           It will look at the modem port and figure out for itself
  520.           what to do.
  521.  
  522.           In the event that the modem carrier is lost, JMODEM will
  523.           abort. Since JMODEM only checks the modem port occasionally,
  524.           it may take several seconds to abort when the carrier is
  525.           lost. It is impossible for a user to get at the DOS level
  526.           through JMODEM. Do NOT use the CTTY command in the external
  527.           protocol batch files. JMODEM returns ERRORLEVEL 1 if there
  528.           was any error in transmission or reception. It returns
  529.           ERRORLEVEL 0 (no error) otherwise. It does not delete files
  530.           that have been partially received although it properly clos-
  531.           es them. The system operator can arrange the batch files to
  532.           delete them if required.
  533.  
  534.           When JMODEM attempts to create a file that already exists it
  535.           can't ask the user if the old one should be deleted since
  536.           the user is probably not in a terminal program at the time.
  537.           Therefore, JMODEM renames the other file to <filename.OLD>
  538.           and creates the new file. In the event that <filaname.OLD>
  539.           exists, it is deleted before the rename operation occurs.
  540.  
  541.           If you don't know what parameters are being sent to external
  542.           protocols, you can make a dummy batch file to check them
  543.           using the DOS's echo command just as explained in the user
  544.           interface previous to this "BBS" section. You can't see the
  545.           parameters being echoed from a remote terminal. You must be
  546.           present at the BBS board terminal to test those parameters
  547.           unless you modify the dummy command file like this:
  548.  
  549.                         @ECHO OFF
  550.                         ECHO %1>COM1
  551.                         ECHO %2>COM1
  552.                         ECHO %3>COM1
  553.                         ECHO %4>COM1
  554.                         ECHO %5>COM1
  555.  
  556.           If you find that your system passes the file name as %3,
  557.           your "upload" (receive) batch file would contain this:
  558.  
  559.                         JMODEM R1 %3
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.                                      - 9 -
  567.           
  568.                                               JMODEM Protocol  Page 10
  569.  
  570.           Your "download" (send) batch file would contain this:
  571.  
  572.                         JMODEM S1 %3
  573.  
  574.           In these examples, it is assumed that you are using
  575.           communications adapter port "1".
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.                                      - 10 -
  630.           
  631.                                               JMODEM Protocol  Page 11
  632.  
  633.                                   The BAD BBS
  634.                                     Problem.
  635.  
  636.           Believe it or not, there are several very fine running BBS
  637.           systems in use that do not properly handle external proto-
  638.           cols. MS-DOS provides the proper mechanism for loading and
  639.           executing "child" programs from within the "parent" pro-
  640.           grams. This is function 4BH of the "DOS" INT 21H DOS inter-
  641.           face. Instead of using this function, these poorly-behaved
  642.           programs perform the external file-transfer protocol in the
  643.           following (or similar) manner:
  644.  
  645.                 (1) Make a DOS call to find the file-size of the
  646.           external file-transfer protocol.
  647.  
  648.                 (2) Free up an array of memory from "string-space"
  649.           within the program that is large enough to copy the external
  650.           file transfer contents into it. As assumption about the
  651.           data-space required by the external file transfer program is
  652.           made based upon the "block-size" information that has been
  653.           entered during configuration.
  654.  
  655.                 (3) Loads the file into string-space memory.
  656.  
  657.                 (4) If its an ".EXE" file, ignore the header.
  658.  
  659.                 (5) CALL the first byte of code!
  660.  
  661.                 If JMODEM is run in this environment, it WILL crash
  662.           the system. JMODEM assumes that it has been placed in memory
  663.           by MS-DOS and that an entire segment (64k) is available to
  664.           run. JMODEM uses two buffers that are almost 32k in length!
  665.           One of the buffers is used to support data compression and
  666.           expansion. The other is used for the interrupt buffer.
  667.  
  668.           If you have such a BBS system and you wish to run JMODEM,
  669.           you can make a simple modification to the source-code, and
  670.           re-compile to produce a version which is a bit slower to
  671.           initialize and exit, but is guaranteed to leave all memory
  672.           and registers EXACTLY as they were when JMODEM got control.
  673.           This is done by saving and restoring all registers. Ad-
  674.           ditionally, any data space that will be modified is copied
  675.           to a file called VIRTUAL.MEM, then restored from that file
  676.           just before JMODEM exits.
  677.  
  678.           You modify the source-code by finding the "BAD_BBS" equate
  679.           near the beginning of the file. This is normally set to
  680.           "FALSE". You set this to "TRUE". Then you recompile in the
  681.           following manner:
  682.  
  683.                 MASM JMODEM;
  684.                 LINK JMODEM;
  685.                 EXE2BIN JMODEM.EXE JMODEM.COM
  686.                 DEL JMODEM.EXE
  687.  
  688.  
  689.  
  690.  
  691.  
  692.                                      - 11 -
  693.           
  694.                                               JMODEM Protocol  Page 12
  695.  
  696.  
  697.           Do NOT attempt to execute the ".EXE" version. You must
  698.           change JMODEM to a ".COM" file. If you do not have
  699.           EXE2BIN.COM to make the change, you can use DOS's DEBUG to
  700.           do the same thing. You do it this way:
  701.  
  702.           F:\DEV> debug jmodem.exe      ; DOS command line
  703.           -rcx                          ; Examine CX register
  704.           CX 1239                       ; Debug says the size was 1239
  705.           :
  706.  
  707.           -h 1239,100                   ; Calculate 1239H - 100H
  708.           1339  1139                    ; Sum = 1339H, dif = 1139H
  709.           -rcx                          ; Examine register again
  710.           CX 1239                       ; Is 1239H
  711.           :1139                         ; Change to 1139H
  712.                                         ; .. subtract 100H
  713.           -njmodem.com                  ; Name new SAVE file name
  714.           -w                            ; Write to file
  715.  
  716.           Writing 1139 bytes            ; Debug prompts
  717.           -q                            ; Exit
  718.  
  719.           F:\DEV>                       ; Back to DOS
  720.  
  721.           When you use this version of JMODEM, it will take a little
  722.           while longer to load and exit because it must write a 64k
  723.           block of memory to a file and read / delete in upon exit.
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.                                      - 12 -
  756.           
  757.                                               JMODEM Protocol  Page 13
  758.  
  759.                             When things don't work!
  760.  
  761.           The early versions of JMODEM assumed that it was being
  762.           properly loaded either by COMMAND.COM, the resident command
  763.           processor, or by a "parent" process that properly executes
  764.           the DOS function 1BH (the EXEC function). Much to my sur-
  765.           prise, I found that much BBS system software is not written
  766.           properly. Starting at version V1.10, I included the
  767.           "BAD_BBS" routines to help overcome some of the loading
  768.           problems that these BBS systems have. In some cases this
  769.           work-around was successful and in others it was not. In
  770.           version V1.13, I included some tests that verify whether or
  771.           not JMODEM has been loaded properly. Instead of crashing the
  772.           system, JMODEM now prints an error message and exits. These
  773.           error messages can help you find out what the problem is
  774.           and, hopefully, obtain a solution.
  775.  
  776.           Presently, when JMODEM is loaded one of the first things it
  777.           does is make a DOS call to give up all memory except that
  778.           which contains the code. If DOS returns an error, it means
  779.           that JMODEM was not loaded properly and therefore doesn't
  780.           own any memory to give up! If an error message appears
  781.           telling you that JMODEM doesn't own any memory, you must
  782.           contact the writer of your BBS system software to obtain a
  783.           version that has this bug fixed. There will be no way to
  784.           execute JMODEM in this kind of environment without risking
  785.           serious system crashes.
  786.  
  787.           The next thing JMODEM does is make a DOS call, requesting
  788.           64k (-1) bytes of memory for its necessary buffer space. If
  789.           this DOS call fails, a message is printed stating that there
  790.           is not enough memory available for JMODEM. In this case, you
  791.           simply reconfigure your BBS software to provide enough mem-
  792.           ory for the external protocol. On some BBS systems, this is
  793.           done by defining "block-size". Generally, you just specify
  794.           the largest number that your BBS software will accept and
  795.           therefore force the BBS system software to allocate a large
  796.           block of memory for the external protocol.
  797.  
  798.           Although the code size of JMODEM is small (around 4k), it
  799.           requires just as much memory as other external protocols.
  800.           The memory is used for three major buffers:
  801.                 (1) Data buffer  8198 bytes
  802.                 (2) Encode/decode buffer 32,767 bytes
  803.                 (3) Interrupt buffer 20,000 bytes
  804.  
  805.           These buffers are put in a separate segment so a wild bit-
  806.           stream input cannot cause a system crash. The index used for
  807.           addressing memory in the interrupt buffer simply wraps
  808.           around past 64k, back to zero. Of course you get data errors
  809.           when this happens, but no crash, and if the incoming bit-
  810.           stream ends before a time-out, the error is recoverable.
  811.           When satellite links lose lock, the result is usually a 20
  812.           to 30 second burst of noise (random bit-stream). At 9600
  813.  
  814.  
  815.  
  816.  
  817.  
  818.                                      - 13 -
  819.           
  820.                                               JMODEM Protocol  Page 14
  821.  
  822.           baud, you can easily overflow a buffer if it is not large
  823.           enough or is not allowed to wrap. Alternative methods are to
  824.           limit the size of the buffer and check the limit every time
  825.           a byte is put in the buffer. JMODEM doesn't do this for two
  826.           reasons. The first is the increased software overhead (the
  827.           check must be made for every byte in the interrupt service
  828.           routine) and the second is that you may be waiting for an
  829.           ACK. JMODEM always preserves the last byte in the buffer so
  830.           that, even with a noisy reverse-channel, the ACK/NAK can be
  831.           extracted.
  832.  
  833.           These are the error messages and what they mean.
  834.  
  835.           JMODEM error message:
  836.           Specified file "" not found
  837.  
  838.           This means that no file name was passed to JMODEM on the
  839.           command line during a download.
  840.  
  841.           JMODEM error message:
  842.           Specified file "\D:PATH\FILENAME.TYP" not found
  843.  
  844.           This means that an incorrect file name was passed to JMODEM
  845.           on the command line during a download.
  846.  
  847.           JMODEM error message:
  848.           Specified file "" Can't be created.
  849.  
  850.           This means that no file name was passed to JMODEM on the
  851.           command line during an upload.
  852.  
  853.           JMODEM error message:
  854.           Specified file "\D:PATH\FILENAME.TYP" Can't be created.
  855.  
  856.           This means that an incorrect file name was passed to JMODEM
  857.           on the command line during an upload or:
  858.  
  859.                 o       The path doesn't exist
  860.                 o       The drive doesn't exist
  861.                 o       Not enough file handles
  862.                         Put FILES=40 in CONFIG.SYS and reboot
  863.                 o       Attempt to write to a network drive
  864.                         If you are not networked, do NOT install SHARE
  865.  
  866.           JMODEM error message:
  867.           File transfer aborted!
  868.  
  869.           This is a normal abort. If the user didn't abort then the
  870.           active communications adapter port is not being passed to
  871.           JMODEM correctly.
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.                                      - 14 -
  882.           
  883.                                               JMODEM Protocol  Page 15
  884.  
  885.           JMODEM error message:
  886.           Modem carrier failed.
  887.  
  888.           Modem either was not online or the user hung up during
  889.           protocol execution.
  890.  
  891.           JMODEM error message:
  892.           Can't execute, no free RAM!
  893.  
  894.           A poorly-written BBS system attempted to load the program as
  895.           a subroutine and execute it. Contact the BBS software
  896.           writer.
  897.  
  898.           JMODEM error message:
  899.           This program was already loaded over resident code.
  900.           The system will probably crash!
  901.  
  902.           A poorly-written BBS system just loaded JMODEM over its own
  903.           code!
  904.  
  905.           JMODEM error message: Can't create file VIRTUAL.MEM
  906.           JMODEM error message: Can't write file VIRTUAL.MEM
  907.           JMODEM error message: Can't close file VIRTUAL.MEM
  908.           JMODEM error message: Can't open file VIRTUAL.MEM
  909.           JMODEM error message: Can't delete file VIRTUAL.MEM
  910.  
  911.           When compiled with the BAD_BBS system conditional set to
  912.           "TRUE", JMODEM was unable to do the required file I/O be-
  913.           cause something was screwed up by the BBS software or there
  914.           were not enough file handles available. Enter FILES=40 in
  915.           CONFIG.SYS and reboot. This can also happen if SHARE is
  916.           installed and no network exists. Do NOT use SHARE if you are
  917.           not networked!
  918.  
  919.           JMODEM error message:
  920.           DOS reports that JMODEM was improperly loaded and does not
  921.           own the memory it is using!
  922.  
  923.           The BBS system software is either improperly configured or
  924.           improperly written for external protocols. Contact the
  925.           writer of the BBS system software.
  926.  
  927.           JMODEM error message:
  928.           Not enough free memory for JMODEM to use!
  929.  
  930.           The BBS system software is not properly configured to give
  931.           JMODEM the memory it requires to execute. Check the BBS
  932.           system software documentation and reconfigure.
  933.  
  934.           If you have problems using JMODEM with your system, you can
  935.           call the PROGRAM EXCHANGE and leave a message You can also
  936.           test your communications program's external file-transfer
  937.           protocols by transferring files (hopefully uploading) to the
  938.           PROGRAM EXCHANGE. Currently there are hundreds of boards
  939.  
  940.  
  941.  
  942.  
  943.  
  944.                                      - 15 -
  945.           
  946.                                               JMODEM Protocol  Page 16
  947.  
  948.           that are using this protocol and the number is growing every
  949.           day. Most problems encountered are found to be caused by
  950.           incorrect file names being sent to JMODEM (the wrong "%"
  951.           parameters). A simple batch file to test these parameters
  952.           will go a long way towards solving the problems.
  953.  
  954.                                 Richard B. Johnson
  955.                                 PROGRAM EXCHANGE
  956.                                 (303) 440-0786
  957.                                 Boulder Colorado
  958.                                 80303
  959.  
  960.           - Finis -
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.                                      - 16 -
  1008.           
  1009.